public class test05 {
    class Solution {
        public String intToRoman(int num) {
            int[] val = new int[]{1000,900,500,400,100,90,50,40,10,9,5,4,1};
            String[] str = new String[]{"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
            StringBuilder sb = new StringBuilder();
            for(int i = 0;i<val.length && num>0 ;i++){
                while(val[i]<=num){
                    sb.append(str[i]);
                    num -= val[i];
                }
            }
            return sb.toString();
        }
    }
}
